package com.leetcode.LC;

import java.util.Arrays;

public class LC153 {
    public int findMin(int[] nums) {

        if (nums.length == 1) {
            return nums[0];
        }
        for (int i = 1; i < nums.length; i++) {
            if (nums[i - 1] > nums[i]) {
                return nums[i];
            }
        }
        if (nums[0] < nums[1])
            return nums[0];
        else
            return nums[nums.length - 1];
    }
    public int findMin2(int[] nums) {
        Arrays.sort(nums);
        return nums[0];
    }

    public static void main(String[] args) {
        System.out.println(new LC153().findMin(new int[]{10,9,8,7}));

    }
}
